package com.javawork.igossip;

import android.os.Bundle;
import android.app.Activity;
import android.app.ListActivity;
import android.content.Intent;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.view.Menu;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;
import com.javawork.igossip.model.*;

public class TabContactListActivity extends ListActivity {

	ListView list_contact;
	TextView text_topbar;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_tab_contact_list);
		text_topbar = (TextView) getParent()
				.findViewById(R.id.text_main_topbar);
		text_topbar.setText(R.string.title_activity_tab_contact_list);
		list_contact = getListView();
		setListAdapter(new ArrayAdapter<String>(this,
				R.layout.contact_list_item, new String[] { "a", "b", "c", "a",
						"b", "c", "a", "b", "c", "a", "b", "c", "a", "b", "c" }));
		list_contact.setOnItemClickListener(new OnItemClickListener() {

			@Override
			public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
					long arg3) {
				// TODO Auto-generated method stub
				User user = new User();
				user.setAllInfo("Han meimei", "Hello~",
						BitmapFactory.decodeResource(getResources(),
								R.drawable.avatar_dummy), new String[] { "A",
								"B" });
				//Bundle userbundle = new Bundle();
				//userbundle.putSerializable("user", user);
				Intent intent = new Intent(TabContactListActivity.this,
						ContactDetailActivity.class);
				User.publicUser = user;
				//intent.putExtra("user", userbundle);
				startActivity(intent);
			}
		});
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.tab_contact_list, menu);
		return true;
	}

}
